! function () {
  let elThead = $$('.el-table__header-wrapper > table > thead > tr > th')
  let ivuThead = $$('.ivu-table-header > table > thead > tr > th')
  let bodyQuery = ''
  let head = null
  if (elThead.length) {
    head = elThead
    bodyQuery = ".el-table__body-wrapper > table > tbody > tr"
  } else if (ivuThead.length) {
    head = ivuThead
    bodyQuery = ".ivu-table-body > table > tbody > tr"
  } else {
    return alert("当前页面没有el-table或ivu-table!")
  }
  let thead = head.map(v => v.textContent).join('|').replace(/^|$/g, '|')
  let align = new Array(head.length).fill(':--:').join('|').replace(/^|$/g, '|')
  let tbody = Array.from($$(bodyQuery)).map(v => Array.from(v.children).map(t => t.textContent).join('|').replace(/^\|*/, '|').replace(/\|*$/, '|')).join('\n')
  let str = `${thead}\n${align}\n${tbody}`
  let blob = new Blob([str])
  let url = window.URL.createObjectURL(blob)
  let a = document.createElement('a')
  document.body.appendChild(a)
  a.download = `${new Date().toLocaleString()}.md`
  a.href = url
  a.click()
  document.body.removeChild(a)
}()
